import BaseUtil from '@/BaseUtil';
import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import MovementCommon from 'code/Core/Common/MovementCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
import GameMonsters from 'code/Scripts/GameMonster';
/**
 * 寄生蛛卵
 **/
export default class BossSpell_ZhuLuan extends AbilityBase {
    static instance: BossSpell_ZhuLuan;
    buffType: AppBuffType = {
        id: 'buff_BossSpell_ZhuLuan',
        art: this.art,
        name: this.abilityName,
        ubertip: this.ubertip,
        targetAttach: 'overhead',
        targetArt: 'Abilities\\Spells\\Other\\Parasite\\ParasiteTarget.mdl',
        dur: 5,
        attribute: {
            attackSpd_p: -0.8,
            move_speed_p: -0.5,
        },
        onDestroy: this.onBuffDestroy.bind(this),
        onInterval: this.onBuffInterval.bind(this),
        interval: 1,
        isDebuff: true,
    };
    onBuffDestroy(buff: Buff) {
        DestroyEffect(AddSpecialEffectTarget('Abilities\\Weapons\\HydraliskImpact\\T_HydraliskImpact.mdl', buff.getParent(), 'overhead'));
        let x = GetUnitX(buff.getParent());
        let y = GetUnitY(buff.getParent());
        for (let i = 0; i < 3; i++) {
            GameMonsters.create('nspr', x, y);
        }
    }
    onBuffInterval(buff: Buff) {
        DamageSystemInstance.applyPoisionDamage(buff.getParent(), buff.getCaster(), 500, null, true);
    }
    constructor(id: string = 'Azz0') {
        super(id);
        BossSpell_ZhuLuan.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BossAbilityManagerInstance.text('寄生蛛卵', source);
        BaseUtil.runLater(1, () => {
            MovementCommon.TargetMissile({
                missile: 'Abilities\\Spells\\Other\\Parasite\\ParasiteMissile.mdl',
                target: target,
                caster: source,
                speed: 500,
                radian: 0,
                onReach: this.onSkillReach.bind(this),
            });
            source = null;
            target = null;
        });
    }
    onSkillReach(p: TargetMissileConfig) {
        BuffUtil.addBuff(p.target, this.buffType.id, p.caster);
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
